package com.itany.cloud.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 石小俊
 */
@Configuration
public class SwaggerConfig {

    @Bean
    public GroupedOpenApi createApi() {
        return GroupedOpenApi.builder()
                .group("admin-api") // 分组名称
                .pathsToMatch("/**")    // 接口请求的路径规则
                .build();
    }

    @Bean
    public OpenAPI customOpenApi() {
        return new OpenAPI()
                .info(new Info()
                        .title("用户模块的微服务")
                        .description("使用Swagger3构建的用户模块微服务的Restful API接口文档")
                        .contact(new Contact().name("张三").url("https://www.baidu.com/").email("123456@qq.com"))
                        .license(new License().name("Apache 2.0").url("https://docs.spring.io"))
                        .version("1.0"));
    }

}
